*** Settings ***
Documentation    TC14-Push Pricing FCL by Upload
Resource    ../../Keywords/Common_Head.robot
Force Tags    P3
Metadata    Author    Betty
Metadata    ID    6855122


*** Test Cases ***
TC14-Push Pricing FCL by Upload
    Step 1 Go To Pricing Collaboration Push Pricing Start
    Step 2 Select Upload Click On Upload Button
    Step 3 Select FCL Mode Click On Download Button
    Step 4 Click On Add File Upload This File
    Step 5 Input Rate Validate From As Current Date Rate Validate
    Step 6 Click On Cancel
    Step 7 Click On Next Step Button
    Step 8 Move All The Tenders And Tariffs To Right Side
    Step 9 Select Cheapest Rate
    Step 10 Download History And Download IPT
    Step 11 Check The Content Of Two Files
    Step 12 Go To My Results From Left Menu



*** Keywords ***
Step ${step} Go To Pricing Collaboration Push Pricing Start
    #************************Step 1******************************
    #  Do:
    #      Go to Pricing Collaboration Push Pricing Start
    #  Expected:
    #      A page is displayed as
    #      index php attachments get 09b2fd1a c9bd 43da b98e
    #     db6cdfcaeb9e
    #************************************************************
    Login Space
    # Set Browser Timeout    30s
    Navigation Space    Pricing Collaboration    Push Pricing    Start
    Wait For Elements State    //h1[@class='ng-binding']
    Wait For Elements State    //label[.='Tender Name']
    Wait For Elements State    //label[.='Customer Name']
    Wait For Elements State    //label[.='Vertical Market']
    Wait For Elements State    //label[.='Mode']
    Wait For Elements State    //label[.='Tender Lead']
    Wait For Elements State    //label[.='Creation Date']

Step ${step} Select Upload Click On Upload Button
    #************************Step 2******************************
    #  Do:
    #      Select Upload Click on Upload button
    #  Expected:
    #      A dialog is displayed as
    #      index php attachments get 574ffdf5 17c6 4eeb 8be5
    #     c2c4a086f9a5
    #************************************************************
    Click    ${PushPricing_Upload_checkbox}
    Click    ${PushPricing_Upload_Button}
    Wait For Elements State    ${PushPricing_UploadIPT_downloadButton}
    Select Options By    //select[@id='iptMode']    label    FCL

Step ${step} Select FCL Mode Click On Download Button
    #************************Step 3******************************
    #  Do:
    #      Select FCL mode Click on Download button
    #  Expected:
    #      The downloaded file content should be the same as
    #      index php attachments get 99434030 84af 4e2b 987c
    #     a4a03876ae82
    #************************************************************
    ${filename}    Download File    ${PushPricing_UploadIPT_downloadButton}
    Set Test Variable    ${filename}    ${filename}
    Compare Excel Value    ${CURDIR}${/}TestData${/}TC14-FCL Internal Pricing Template-Step3.xlsx
    ...   ${filename}    369    3    sheetName=FCL

Step ${step} Click On Add File Upload This File
    #************************Step 4******************************
    #  Do:
    #      Click on Add file upload this file
    #      index php attachments get e436f457 690e 4cb9 9314
    #     93f597a93b64
    #  Expected:
    #      The Name field is automatically displayed as file name
    #************************************************************
    Upload File By Selector   ${PushPricing_UploadIPT_addFileButton}    ${CURDIR}${/}TestData${/}TC14-FCL Internal Pricing Template-upload-Step4.xlsx
    Wait For Elements State    //button[@data-ng-click='removeFile()']
    ${name}=    Browser.Get Text    ${PushPricing_UploadIPT_NameInput}
    Should Be Equal As Strings     ${name}   TC14-FCL Internal Pricing Template-upload-Step4

Step ${step} Input Rate Validate From As Current Date Rate Validate
    #************************Step 5******************************
    #  Do:
    #      Input Rate Validate From as current date Rate Validate
    #     To as current date 100
    #      Click on Upload
    #  Expected:
    #      Upload SUCCESS
    #************************************************************
    ${CurDate}    Get Current Date    result_format=%d/%m/%Y
    Set Test Variable    ${CurDate}
    ${FutureDate}    Get Current Date    UTC    +100days    result_format=%d/%m/%Y
    Fill Text    ${PushPricing_UploadIPT_validFromInput}     ${CurDate}
    Fill Text    ${PushPricing_UploadIPT_validToInput}    ${FutureDate}
    Click    ${PushPricing_UploadIPT_uploadButton} 
    Wait Until Search Finished
    Wait For Elements State    //span[.='Upload SUCCESS']

Step ${step} Click On Cancel
    #************************Step 6******************************
    #  Do:
    #      Click on Cancel
    #  Expected:
    #      The dialog is closed the Next Step button is enable
    #************************************************************
    Click    ${PushPricing_UploadIPT_cancelButton}

Step ${step} Click On Next Step Button
    #************************Step 7******************************
    #  Do:
    #      Click on Next Step button
    #      Set Rates valid from 01 01 2021
    #      Click on Next
    #  Expected:
    #      The page displayed as
    #      index php attachments get 50db3f54 f8ad 4d99 af7a
    #     3163fe5f227b
    #************************************************************
    Wait For Elements State    ${PushPricing_Start_nextButton}    enabled
    Click    ${PushPricing_Start_nextButton}
    Fill Text    ${PushPricing_step1_validFrom}    01/01/2021
    Click    ${PushPricing_step1_nextButton}
    Wait For Elements State    //h1[.='Step 2 - Tenders & Tariffs']

Step ${step} Move All The Tenders And Tariffs To Right Side
    #************************Step 8******************************
    #  Do:
    #      Move all the tenders and tariffs to right side
    #      Click on Next button
    #  Expected:
    #      The page displayed as
    #      index php attachments get 24acbf9f 7fd3 4567 a485
    #     78e13477b959
    #************************************************************
    click    ${PushPricing_step2_add(activeAvailableItems)} 
    click    ${PushPricing_step2_addTariff(activeAvailableTariffs)}
    Click    ${PushPricing_step1_nextButton}
    Wait For Elements State    //h1[.='Step 3 - Lane Setting']

Step ${step} Select Cheapest Rate
    #************************Step 9******************************
    #  Do:
    #      Select Cheapest Rate
    #      Click on Next
    #  Expected:
    #      After a few minutes The page displayed as the tender
    #     name pricing lead Date and Time Hit Raito maybe
    #     different
    #      index php attachments get c0a7f6ee 3467 4833 be04
    #     74eee919414a
    #************************************************************
    Check Checkbox   ${PushPricing_step3_Cheapest Rate}
    # Check Checkbox    ${PushPricing_step3_selectall}
    Click    ${PushPricing_step1_nextButton}
    Sleep    2min
    Wait For Elements State    //h1[.='Step 4 – View Results']    visible    10min

Step ${step} Download History And Download IPT
    #************************Step 10******************************
    #  Do:
    #      Download History and Download IPT
    #  Expected:
    #      The two files can be downloaded successfully
    #************************************************************
    Click    xpath = //td[contains(text(),'TC14-FCL Internal Pricing Template-upload-Step4')]
    Click    xpath = //td[contains(text(),'Automation Tester(AUTOTEST)')]
    # Click    xpath = //td[contains(text(),'85%')]      #may be different       
    Click    xpath = //td[contains(text(),'${CurDate}')]  
    ${Hit Ratio}    Get Text    ((//td[contains(text(),'${G_TENDERID}')])[1]/../td)[4]
    ${Hit Ratio}    Remove String    ${Hit Ratio}    %
    should be true    ${Hit Ratio}>0

Step ${step} Check The Content Of Two Files
    #************************Step 11******************************
    #  Do:
    #      Check the content of two files
    #  Expected:
    #      Should have same format as
    #      index php attachments get 8126bd38 c9d1 4d32 8100
    #     319be737a3c8 index php attachments get 7af9a4f4 7718
    #     4f97 a9e1 3e9eea5a5bad
    #************************************************************
    ${filename1}    Download File    ${PushPricing_step4_DownloadIPTButton}
    Compare Excel Value    ${CURDIR}${/}TestData${/}TC14-FCL Internal Pricing Template-Step11_1.xlsx
    ...    ${filename1}    369    3    sheetName=FCL
    ${filename2}    Download File    ${PushPricing_step4_DownloadHistoryButton}
    Compare Excel Value    ${CURDIR}${/}TestData${/}TC14-FCL Internal Pricing Template-Step11_2.xlsx
    ...    ${filename2}    369    3    sheetName=FCL
    # check with wendy


Step ${step} Go To My Results From Left Menu
    #************************Step 12******************************
    #  Do:
    #      Go to My Results from left menu
    #  Expected:
    #      The first record in the list is the one which displayed
    #     as step 9
    #************************************************************
    Sleep    2
    Click    //a[.='My Results']
    Wait For Elements State    //h1[.='My Results'] 
    Click    xpath = //tbody/tr[1]/td[contains(text(),'TC14-FCL Internal Pricing Template-upload-Step4')]
    Click    xpath = //tbody/tr[1]/td[contains(text(),'Automation Tester(AUTOTEST)')]
    # Click    xpath = //tbody/tr[1]/td[contains(text(),'85%')]      #may be different       
    Click    xpath = //tbody/tr[1]/td[contains(text(),'${CurDate}')] 
    ${Hit Ratio}    Get Text    ((//td[contains(text(),'${G_TENDERID}')])[1]/../td)[4]
    ${Hit Ratio}    Remove String    ${Hit Ratio}    %
    should be true    ${Hit Ratio}>0

